/**
 * 时间复杂度 O(n2)
 * @param {*} arr 
 * @returns 
 */
function selectSort(arr) {
    let length = arr.length
    for (let i = 0; i < length-1; i++) {
        let indexMin = i
        for (let j = i + 1; j < length; j++) {
            //第一遍找出最小的那个数
            if (arr[indexMin] > arr[j]) {
                indexMin = j
            }
        }
        //寻找完了后在进行交换
        let count = arr[i]
        arr[i] = arr[indexMin]
        arr[indexMin] = count
    }
    return arr
}
let test = [1, 6, 3, 2, 7, 22, 6, 8, 9, 10, 16]
console.log(selectSort(test));